package com.tensquare.friend.dao;

import com.tensquare.friend.pojo.Friend;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * Created by WF on 2020/10/27 10:50
 */
public interface FriendDao extends JpaRepository<Friend, String> {

    //1.查询用户及其好友在数据库中是否存在
    @Query(nativeQuery=true,value="select count(*) from tb_friend where userid=?1 and friendid=?2")
    int selectCount(String userid, String friendid);

    //2.修改islike的值
    @Modifying
    @Query(nativeQuery=true,value="update tb_friend set islike=?1 where userid=?2 and friendid=?3 ")
    void updateIsLike(String islike, String userid, String friendid);

    //3.删除好友
    @Modifying
    @Query(nativeQuery=true,value="delete from tb_friend where userid=?1 and friendid=?2")
    void deleteFriend(String id, String friendid);
}
